<template>
  <div class="wrapper">
    <swiper :options="swiperOption" v-if="showSwiper" >
      <!-- slides -->
      <swiper-slide v-for="item in list" :key="item.id">
        <img class="swiper-img" :src="item.imgUrl" alt="">
      </swiper-slide>
      <!-- Optional controls -->
      <div class="swiper-pagination"  slot="pagination"></div>
    </swiper>
  </div>
</template>
<script>
export default {
  name: 'HomeSwiper',
  data () {
    return {
      swiperOption: {
        pagination: ' .swiper-pagination',
        loop: true
      },
      swiperList: [{
        id: '0001',
        imgUrl: 'https://p2-q.mafengwo.net/s12/M00/AD/5B/wKgED1vgNKiAL3UqAAktryfr7vE49.jpeg?imageMogr2%2Fthumbnail%2F%21750x422r%2Fgravity%2FCenter%2Fcrop%2F%21750x422%2Fquality%2F90'
      }, {
        id: '0002',
        imgUrl: 'https://n1-q.mafengwo.net/s12/M00/AF/83/wKgED1vgNnqAYlbnAAgr8m_JjBw63.jpeg?imageMogr2%2Fthumbnail%2F%21750x422r%2Fgravity%2FCenter%2Fcrop%2F%21750x422%2Fquality%2F90'
      }
      ]
    }
  },
  props: {
    list: Array
  },
  computed: {
    showSwiper () {
      return this.list.length
    }
  }
}
</script>

<style scoped lang="stylus">
  /*.wrapper*/
    /*overflow hidden*/
    /*width: 100%*/
    /*height 0*/
    /*padding-bottom:31.25%*/
    /*background: #eee*/
   .wrapper >>> .swiper-pagination-bullet-active
     background: #fff
    .swiper-img
      width: 100%
      height 3rem
</style>
